<?php require_once('function.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>gsUnity</title>

	<?php echo GetJsCss();?>

<script type="text/javascript">
	var aJaxURL			= "worker.action.php";					//server side folder url
	$(document).ready(function () {
		GetMainDialog("dialog",1016,746);
		GetLOgDialog("login-form",460,300);
		var buttons = {
		        "yes": {
		            text: "კი",
		            id: "yes-dialog",
		            click: function () {
		            }
		        },
		        "no": {
		            text: "არა",
		            id: "no-dialog",
		            click: function () {		        	
		        		GetServise();
		        		$("#alternative-form").dialog("open");

		            }
		        }
		};
		GetAskDialog("check-form", "auto", "auto", buttons);
		var buttons = {
		        "save": {
		            text: "შენახვა",
		            id: "save-dialog",
		            click: function () {
		            	SavePart(0);
		        		$("#alternative-form").dialog("close");
		        		$("#check-form").dialog("close");
		        	//	$("#alternative-form").html("");
		        		//$("#check-form").html("");
		        	//---------------------------------------------
		            }
		        }
		};
		GetAskDialog("alternative-form", "auto", "auto", buttons);
		getPartTable();
		getWorkerTable();
		getInfoTable();

		$("#user").on("click", function() {
			$(".results").css({'display':'inline', 'zoom':'1'});
		});

		$("#active_catridgeBacode").focus();
		$('#ok_part').blur();

		$("#password").keyboard({

			 display: {
			  'bksp'   : '\u2190',
			  'enter'  : 'return',
			  'default': 'ABC',
			  'accept' : '\u21d3'
			 },

			 layout: 'custom',

			 customLayout: {

			  'default': [
			   '1 2 3',
			   '4 5 6',
			   '7 8 9',
			   '0 {bksp} {accept}'
			  ]
			 }

		});

	    $("#part_list_tbody").on("click", "#clickID", function () {
	        var rID = $("#type", this).text();

	        if( $("#checkbox_"+rID).is(":checked") ){
	        	$("#checkbox_"+rID).prop('checked', false);
	        }else{
	        	$("#checkbox_"+rID).prop('checked', true);
	        }
	    });

	    $("#log-in").css( "height","40px" );
	    $("#log-out").css( "height","40px" );
	    $("#ok_part").css( "height","40px" );
	});

	$(document).on("click", ".button", function () {
		$("#"+$("#active").val()).removeClass("hver");
		$("#active").val(this.value);
		$("#"+this.value).addClass("hver");
		GetNotify1("დაასკანერეთ პრინტერი!");
		$("#barcode_input").focus();
	});

	$(document).on("keydown", "#barcode_input", function () {
		if (event.keyCode == $.ui.keyCode.ENTER){
			$("#active_catridgeBacode").val( $("#barcode_input").val() );
			$("#barcode_input").val("");
			getInfoTable();
        }
	});

	$(document).on("click", "li", function (event) {
		$("#user").val( $(this).html() );
		$(".results").css({'display':'none', 'zoom':'1'});
		event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
	});

	$(document).on("click", "#ok_part", function (){
		if( $("#active_catridgeBacode").val() != "" ){
			$('#alternative_part_tbody').html('');
			$("#check-form").dialog("open");
			showSelecedPart();
			$('#yes-dialog').blur();
		}
	});

	$(document).on("click", "#yes-dialog", function (){
		SavePart(1);
		$("#active_catridgeBacode").val();
		$(".button").removeClass("hver");
		$("#active").val("");

		getPartTable();
		getInfoTable();
		getHistoryTable();
	});

	$.expr[":"].containsIN = $.expr.createPseudo(function(arg) {
		
	    return function( elem ) {		
	        return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
	    };
	});
	
function  find(th){
	if($(th).val()=='') {$("#alternative_part_tbody tr").show(); return 0};
	  $("#alternative_part_tbody tr").hide();
     $("#alternative_part_tbody :containsIN('"+ $(th).val()+"')").each(function () {   
	  $(this).show()
});
   
  }

</script>
<style>
.red{
    background: red;
}
.red{
    : red;
}
</style>
</head>
<body style="background: #E2F0FD url(../media/images/bg.png);">

<div id="dialog" title="სამუშაო გვერდი" style="padding: 2px 2px 0px 10px !important;" onselectstart='return false;'>
	<table id="main-table"  border=0>
		<tr>
			<td rowspan="2">
				<fieldset style="width: 185px; overflow:auto; height: 620px;" >
				<legend><span>ამჟამად მუშაობენ </span></legend>
					<table id="worker_list" style="width: 175px;border-collapse:collapse;" >
						<tbody id="worker_list_tbody">
						</tbody>
					</table>
				</fieldset>
			</td>
			<td rowspan="2" >

				<fieldset  style="height: 620px; width: 310px; overflow:auto" >
			    	<legend>სამუშაო მხარე</legend>
			    	<div class="partdiv">			    	    
						<table class="tableClass" id="part_list"  style="width: auto;  vertical-align: baseline;"  cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
							<thead>
								<tr class="trClass">
									<th class="thClass" style="width: 200px;">ტიპი<br/></th>
									<th class="thClass">#</th>
								</tr>
							</thead>
							<tbody id="part_list_tbody">
							</tbody>
						</table>
					</div>
					<div class="ui-dialog-buttonset" style="float:right; padding-right:25px; padding-top:3px;">
					<button type="button" id="ok_part" style="outline:none;"class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
						<span class="ui-button-text">შეცვლა</span>
					</button>
					</div>
					<div>
						<input type="text" style="opacity:0;filter:alpha(opacity=0); width: 0px; display: inline; padding: 0px;" id="barcode_input" value=""/>
					</div>
				</fieldset>
			</td>

			<td>

				<fieldset style="width: 440px;overflow:auto; height: 200px " >
					<legend><span>ინფორმაცია პრინტერზე</span></legend>

					<table id="info_list"  style="float: left; font-family: BPG arial; font-weight: normal;"  class="dialog-form-table" cellspacing='8'>
						<tbody id="info_list_tbody">
						</tbody>
					</table>


				</fieldset>
			</td>
		</tr>
		<tr>
			<td>
				<fieldset style="height: 408px; width: 440px; overflow:auto" >
				<legend><span>ისტორია</span></legend>
				<div class="historydiv" >
					<table class="tableClass" id="history_list"  style="width: auto;"  cellspacing='0' style=" vertical-align: baseline;"> <!-- cellspacing='0' is important, must stay -->
						<thead>
							<tr class="trClass">
								<th class="thClass" style="width: 250px;">ტიპი</th>
								<th class="thClass" style="width: 30px;">სულ</th>
								<th class="thClass" style="width: 40px;">ბოლო გამოცვლა</th>
							</tr>
						</thead>
						<tbody id="history_list_tbody">
						</tbody>
					</table>
				</div>
				</fieldset>
			</td>
		</tr>
	</table>
</div>

<div id="login-form" title="სისტემაში შესვლა">
		<fieldset>
			<legend>ძირითადი ინფორმაცია</legend>
			<table width="80%" class="dialog-form-table" cellpadding="10px" >
				<tr	style="float: left">
					<th>
						<label for="user">მომხმარებელი</label>
					</th>
					<th>
						<input id="user"  class="user_input" style="display: inline-block;" autocomplete="off"/>
						<div class="results">
							<ul id="results_list"></ul>
						</div>
					</th>
				</tr>
				<tr style="float: left">

					<th>
						<label for="password">პაროლი&emsp;&emsp;&emsp;&nbsp;</label>
					</th>
					<th>
						<input id="password" class="user_input" type="password" autocomplete="off"/>
      				</th>

				</tr>
			</table>
		</fieldset>
</div>

<div id="check-form" title="მარაგიდან ჩამოკლდეს ?">
				<fieldset style="width: 310px;" >
			    	<legend>სერვისეიბის ჩანათვალი</legend>
			    	<div>
						<table class="tableClass" id="seleced_part_list"  style="width: auto;  vertical-align: baseline;"  cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
							<thead>
								<tr class="trClass">
									<th class="thClass" style="width: 200px;">ტიპი</th>
									<th class="thClass">#</th>
								</tr>
							</thead>
							<tbody id="seleced_part_list_tbody">
							</tbody>
						</table>
					</div>
				</fieldset>
</div>

<div id="alternative-form" title="მარაგიდან ჩამოკლება">
				<fieldset>
			    	<legend>სერვისეიბის ჩანათვალი</legend>
			    	<div class="partdiv1">
						<table class="tableClass" id="alternative_part"  style="width: auto;  vertical-align: baseline;"  cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
							<thead>
								<tr class="trClass">
									<th class="thClass" style="width: 200px;">ტიპი <input onkeyup="find(this)" style="width: 200px; color: black; background: #fff;" class="inpt" type="text"/></th>
									<th class="thClass">#</th>
								</tr>
							</thead>
							<tbody id="alternative_part_tbody">
							</tbody>
						</table>
					</div>
				</fieldset>
</div>

<div >
	<input type="hidden" id="active" value=""/>
</div>
<div >
	<input type="hidden" id="active_catridgeBacode" value=""/>
</div>
</body>
</html>